//
//  HomeTodayGoodsCollectionViewCell.m
//  share_business
//
//  Created by 吴于凌 on 2017/9/2.
//  Copyright © 2017年 wyl. All rights reserved.
//

#import "HomeTodayGoodsCollectionViewCell.h"


@interface HomeTodayGoodsCollectionViewCell ()

@property (nonatomic,strong)UIScrollView *scrollView ;
@end

@implementation HomeTodayGoodsCollectionViewCell


-(void)setUpView {
    
}
-(void)setModel:(id)model{
    int width = 150 ;
   
    if (!_scrollView) {
        _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, APPWIDTH, self.height)];
        _scrollView.showsHorizontalScrollIndicator = NO;
    }
    [_scrollView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    for (int i = 0; i<10; i++) {
        UITapGestureRecognizer*tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickGoods)];
       
        
        UIView *bgView  = [[UIView alloc]initWithFrame:CGRectMake(i*width + 10, 0, width - 10, self.height - 10)];
        [bgView addGestureRecognizer:tapGesture];
        [bgView setBorder:1 cornerRadius:0];
        
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, bgView.width, self.height * 2 / 3)];
        [BSCommon setImageWithUrl:imageView url:nil];
        [bgView addSubview:imageView];
        
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, imageView.maxY - 1, bgView.width, 1)];
        line.backgroundColor = [UIColor colorWithHexString:@"#dddddd"];
        [bgView addSubview:line];
        
        
        
        UIView *bottomView = [[UIView alloc]initWithFrame:CGRectMake(0, imageView.maxY, bgView.width, bgView.height - imageView.height)];
        bottomView.backgroundColor = [UIColor colorWithHexString:@"#f8f8f8"];
        [bgView addSubview:bottomView];
        
        UILabel *title = [BSWidget commonLableWithFrame:CGRectMake(14, 0, bgView.width-28, 30) text:@"法国克侯爵红酒" color:nil font:15];
        title.textColor = RGBA(51, 51, 51, 1);
        [bottomView addSubview:title];
        
        NSString *oldValueStr = @"1035";
        UILabel *oldValue = [BSWidget commonLableWithFrame:CGRectMake(14, title.maxY, 80 , 25) text:@"1035" color:nil font:15];
         oldValue.textColor = RGBA(51, 51, 51, 1);
        NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:oldValueStr];
        [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, oldValueStr.length)];
        [attri addAttribute:NSStrikethroughColorAttributeName value:RGBA(51, 51, 51, 1) range:NSMakeRange(0, oldValueStr.length)];
        [oldValue setAttributedText:attri];
        
        
        [bottomView addSubview:oldValue];
        
        UILabel *newestValue = [BSWidget commonLableWithFrame:CGRectMake(bgView.width-60, 26, 60, 40) text:@"699" color:[UIColor orangeColor] font:20];
        [bottomView addSubview:newestValue];
        
        [_scrollView addSubview:bgView];
        
    }
    _scrollView.contentSize = CGSizeMake(width * 10, self.height) ;
 
    [self addSubview:_scrollView];
    
}

-(void)clickGoods{
    if (self.delegate) {
        [self.delegate todayClickCallBack ];
    }
}
@end
